const { resolve,join } = require('path');
const htmlWebpackPlugin = require('html-webpack-plugin');

module.exports = {
	mode: 'development',
	target: 'web',
	entry: './src/index.js', // 参照本配置文件的相对路径
	output: {
		filename: 'main.js',
		path: resolve(__dirname,'dist')
	},

	devServer: {
		port:9000,
	    proxy: {
	      '/api': {
	      	// https://www.xdfznh.club/wxpadbe/user/g - 获取所有微信用户
	        target: 'https://www.xdfznh.club/wxpadbe',
	        pathRewrite: {'^/api' : ''},
	        changeOrigin: true,     // target是域名的话，需要这个参数
	        secure: false,          // 设置支持https协议的代理
	      },

	      '/ap': {
	      	// https://www.jzy.world/wxbe/mill/all - 获取所有客户
	        target: 'https://www.jzy.world/wxbe',
	        pathRewrite: {'^/ap' : ''},
	        changeOrigin: true,     // target是域名的话，需要这个参数
	        secure: false,          // 设置支持https协议的代理
	      }
	    }
  	},

	plugins: [
		new htmlWebpackPlugin({
			template: "./src/index.html",
			//filename: "entry.html" 可变更默认文件名
		})
	]
}